package com.zhang.serviceorder.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * 类功能描述
 *
 * @author Kye
 * @date 2025-04-19
 */
@Component
public class RedisConfig {
	private String protocol = "redis://";

	@Value("${spring.redis.host}")
	private String redisHost;

	@Value("${spring.redis.port}")
	private int redisPort;

	@Bean
	public RedissonClient redissonClient() {
		Config config = new Config();
		config.useSingleServer().setAddress(protocol + redisHost + ":" + redisPort).setDatabase(0);
		return Redisson.create(config);
	}
}
